package com.czh.dao.Role;

import com.czh.dao.BaseDao;
import com.czh.pojo.Role;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class RoleDaoImpl implements RoleDao{
    @Override
    public List<Role> getRole(Connection con) throws SQLException {
        PreparedStatement pre = null;
        List<Role> roleList = new ArrayList<Role>();
        if(con!=null){
            String sql ="select * from smbms_role";
            Object[] pram = {};
            ResultSet res = BaseDao.getSelect(con, pre, null, sql, pram);
            Role role;
            while (res.next()){
                role = new Role();
                role.setId(res.getInt("id"));
                role.setRoleName(res.getString("roleName"));
                role.setRoleCode(res.getString("roleCode"));
                roleList.add(role);
            }
            BaseDao.closeConnect(con,pre,res);
        }
        return roleList;
    }
}
